package com.mdc.admin.component;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;

/**
 * mdc日志打印测试
 *
 * @author pcheng reviewcode@163.com
 * @date 12:06 2021/8/1
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class MdcPrinter {
    private final ThreadPoolTaskExecutor threadPoolTaskExecutor;

    public void printLog() {
        log.info("{}", System.currentTimeMillis());

        CompletableFuture.runAsync(() ->
                log.info("异步线程")
        , threadPoolTaskExecutor);
    }
}
